<include file="header"/>
<div class="wrapper white-bg">
    <div>
        <img src="/assets/base/EastSoftSurveillance/images/header.jpg" alt="">
    </div>
    <form  method="post" name="form" id="form">
    <div class="content">
        <div class="list flex">
            <div class="icon iconfont icon-iconfontxingming"></div>
            <input class="input" type="text" placeholder="请输入姓名" name="username" id="username">
        </div>
        <div class="list flex">
            <div class="icon iconfont icon-mima"></div>
            <input class="input flex-1" type="text" placeholder="请输入手机号码" name="tel" id="tel" >
            <a href="javascript:void(0)" class="blue send show" id="post">发送验证码</a>
        </div>
        <div class="list flex">
            <div class="icon iconfont icon-mima"></div>
            <input class="input" type="text" placeholder="请输入验证码" name="token" id="token">
        </div>
    </div>
        <a href="javascript:void(0)" class="btn text-center" id="reg">注册</a>

    </form>
</div>
<body>
<script>

    //发送短信请求
    $('#post').click(function(){
        var tel  =$('#tel').val();
        if(tel==''|| tel==null){
            fm.alert('请输入手机号');
            return false;
        }
            var myreg = /^1[34578]\d{9}$/;
            if(!myreg.test(tel))
            {
                fm.alert('请输入有效的手机号码！');
                return false;
            }else{
            $.ajax({
                url:"/base/EastSoftSurveillance/sendText",
                type:"get",
                data:{tel:tel},
                dataType:"json",
                success: function(msg){
                    console.log(msg);

                }
            });
        }

    });

    //点击提交
    $('#reg').click(function(){
        var username =$('#username').val();
        var tel      =$('#tel').val();
        var token    =$('#token').val();
        if(username==''|| username==null){
            fm.alert('请输入用户');
            return false;
        }
        if(tel==''|| tel==null){
            fm.alert('请输入手机号');
            return false;
        }
        var myreg = /^1[34578]\d{9}$/;
        if(!myreg.test(tel))
        {
            fm.alert('请输入有效的手机号码！');
            return false;
        }
        if(token==''|| token==null){
            fm.alert('请输入验证码');
            return false;
        }
            var info = {};
            info.username = username;
            info.tel = tel;
            info.token = token;
            $.ajax({
                'url': "/base/EastSoftSurveillance/index",
                'data': info,
                'dataType':'json',
                'type': 'POST',
                success: function(data) {
                    if (data.status == 'S'){
                        setTimeout("reload('"+data.url+"')", 2000);
                        fm.alert(data.message);

                    }else{
                        fm.alert(data.message);
                        return false;
                    }
                }
            })
    });
    function reload(url) {
        location.href = url;
    }


    var height=$(window).height();
    $('.wrapper').css('minHeight',height);


    //点击获取验证码
    var verifyTag = true;
    $('.list').on('click', '.send', function (e) {
        e.preventDefault();
        if(verifyTag) timeCountDown(this);
        else return;
    });
    // 验证倒计时
    function timeCountDown(elem, seconds) {
        verifyTag = false;
        if(typeof seconds == undefined || seconds == null) seconds = 60;
        setTimeout(function () {
            if(seconds > 0) {
                seconds--;
                $(elem).text('已发送 ' + seconds + 's').addClass('time');
                timeCountDown(elem, seconds);
            } else {
                $(elem).removeClass('time').text('获取验证码');
                verifyTag = true;
            }
        }, 1000);
    }





</script>
</body>
</html>